#include<iostream>
using namespace std;

struct node{
	int point;
	int next;
};
node aa[2000005];
int head[5005]={0};
int js[5005]={0};
int p=0;
void insert(int p1,int p2)
{
	p++;
	aa[p].point=p2;
	aa[p].next=head[p1];
	head[p1]=p;
	js[p1]++;
}

int main()
{
	int n,m;
	cin>>n>>m;
	int p1,p2;
	for (int i=1;i<=m;i++)
	{
		cin>>p1>>p2;
		insert(p1,p2);
		insert(p2,p1);
	}
	
	for (int i=1;i<=n;i++)
	{
		cout<<js[i];
		for (int j=head[i];j>0;j=aa[j].next) cout<<' '<<aa[j].point;
		cout<<endl;
	}
}